var removeElement = function (nums, val) {
  // let curIdx = 0;
  let size = nums.length
  for (let i = 0; i < size; i++) {
    // if (nums[i] !== val) {
    //     nums[curIdx++] = nums[i];
    // }
    if (nums[i] === val) {
      for (let j = i; j < size - 1; j++) {
        nums[j] = nums[j + 1]
      }
      i = i - 1
      size -= 1
    }
  }
  console.log('size', size)
  return size
}
let nums = [0, 1, 2, 2, 3, 0, 4, 2]
removeElement(nums, 2)
console.log('nums==', nums)
